<?php

class TextArea extends FormElement {

	/**
	 * Constructor for the TextField class, passes variables to the FormElement constructor.
	 *
	 * @param String $name
	 */
	public function __construct( $name, array $properties = array() )
	{
		parent::__construct( $name, $properties );
	}

	/**
	 * @see FormElement::__toString()
	 */
	public function __toString() {
		$return =  '
			<div class="form textarea';

		if( in_array( 'tinyMCE', explode( ' ', $this->getProperty( 'class' ) ) ) ||
			in_array( 'tinyMCEsmall', explode( ' ', $this->getProperty( 'class' ) ) ) ) {
			$return .= ' tinyMCE';
		}

		$return .= '"><label for="' . ( $this->getFormName() != '' ? $this->getFormName() . '_' : '' ) . $this->name . '">' . $this->getProperty("label") . '</label><textarea rows="'.$this->getProperty("rows").'" cols="' . $this->getProperty("cols") . '" name="' . ( $this->getFormName() != '' ? $this->getFormName() . '_' : '' ) . $this->name . '" id="' . ( $this->getFormName() != '' ? $this->getFormName() . '_' : '' ) . $this->name . '" class="'.$this->getProperty('class').'" style="' . $this->getProperty('style') . '">' . $this->value . '</textarea>
				' . ( $this->inAJAXMode() || !empty( $this->errorMessage ) ? '<div class="error' . ( $this->inAJAXMode() ? ' ajax' : '' ) . '" id="' . ( $this->getFormName() != '' ? $this->getFormName() . '_' : '' ) . $this->name . '_error">' . $this->errorMessage . '</div>' : '' ) . '</div>';

		return $return;
	}
}

